home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ham Radio
/
Ham Radio CD-ROM (Emerald Software) (1995).ISO
/
cw
/
morse-it
/
morse-it.bas
next >
Wrap
BASIC Source File
|
1989-06-23
|
5KB
|
136 lines
10 CLS:SCREEN 0:KEY OFF:DIM A$(40):SP=30000
20 FOR X= 1 TO 40 :READ A$(X):NEXT X
30 H$="abcdefghijklmnopqrstuvwxyz0123456789?/-."
40 CLS:PRINT"MORSE-IT! An italian `quick & dirty' Morse tutor";
50 PRINT "It transmits Morse characters in 3 ways :" : PRINT
60 PRINT " D - keyboard-Directed":
70 PRINT " A - rAndom strings (5 chars. long)"
80 PRINT " F - taking input from a File" : PRINT
90 PRINT "allowing user to choose : "
100 PRINT " speed (default 40 chars. per minute)"
110 PRINT " oscillator tone (default 700 Hz)":PRINT
120 PRINT "and selecting output device between screen or printer "
130 PRINT "(screen by default)"
140 PRINT : PRINT "You can also `receive' Morse characters keyed-in"
150 PRINT "via the game port. See MORSE-IT.DOC for details on"
160 PRINT "how to connect the key or input device."
170 PRINT:PRINT"by IW2CNM - ALESSANDRO BRUCIAMONTI "
180 PRINT "via Roma 72 ":PRINT "27047 - S.Maria della Versa (PV)"
190 PRINT "ITALY"
200 PRINT:INPUT "rAndom, File, keyboarD, Receive [a f d r] ";K$
210 IF K$="" THEN 200
220 K$=CHR$(ASC(K$) OR 32)
230 IF K$<>"a" AND K$<>"d" AND K$<>"f" AND K$<>"r" THEN 200
240 IF K$="r" THEN 820
250 CLS:INPUT "Speed (10-130 chars./min.):";V$:V=VAL(V$):IF V=0 THEN V=40
260 IF V<10 OR V>130 THEN 250
270 INPUT "Tone (100-7000 Hz) :";F$:F=VAL(F$):IF F=0 THEN F=700
280 IF F<100 OR F >7000 THEN 270
290 V=60/V:INPUT "Printer echo ";D$:IF D$="" THEN D$="n"
300 D$=CHR$(ASC(D$) OR 32) : IF D$<>"s" AND D$<>"n" THEN 290
310 IF D$="s" THEN OPEN "prn" FOR OUTPUT AS #1:PR=-1
320 IF K$<>"a" THEN 530
330 REM
340 REM 23 Lines of 13 Strings of 5 Characters are to be transmitted
350 REM
360 CLS:FOR L=1 TO 23:FOR S=1 TO 13:FOR C=1 TO 5
370 RANDOMIZE(TIMER):X=INT(RND(TIMER)*39+1)
380 IF X>40 OR X<1 THEN 370
390 C$=MID$(H$,X,1):PRINT C$;:IF PR THEN PRINT#1,C$;
400 GOSUB 460:NEXT C
410 PRINT " ";:SOUND SP,V*7:IF PR THEN PRINT#1," ";
420 NEXT S:PRINT CHR$(13);:IF PR THEN PRINT#1,CHR$(13)+CHR$(10)
430 NEXT L:PRINT"Press a key to continue...ESC to exit."
440 O$=INKEY$:IF O$="" THEN 440 ELSE IF O$<>CHR$(27) THEN 360
450 CLOSE 1:END
460 SOUND SP,V*5:FOR M=1 TO LEN(A$(X)):Z$=MID$(A$(X),M,1)
470 IF Z$="1" THEN SOUND F,V*3
480 IF Z$="0" THEN SOUND F,V
490 SOUND SP,V:NEXT M:RETURN
500 DATA 01,1000,1010,100,0,0010,110,0000,00,0111,101,0100,11,10,111,0110,1101
510 DATA 010,000,1,001,0001,011,1001,1011,1100,11111,01111,00111,00011,00001
520 DATA 00000,10000,11000,11100,11110,001100,10010,10001,000000
530 IF K$<>"f" THEN 660
540 CLS: PRINT "File input section ":PRINT:PRINT
550 INPUT "name of file to open (12 chars. max) "; NF$
560 NF$=LEFT$(NF$,12)
570 ON ERROR GOTO 550
580 OPEN NF$ FOR INPUT AS #2
590 ON ERROR GOTO 1330
600 WHILE NOT EOF(2)
610 C$=INPUT$(1,#2)
620 GOSUB 720
630 REM
640 WEND :CLOSE #2
650 GOTO 540
660 CLS: PRINT "Keyboard-directed input section :"
670 PRINT "input lines with <ENTER> key "
680 PRINT "an `*' as first character of the line ends program "
690 PRINT:INPUT Y$:IF Y$="*" THEN END
700 FOR II=1 TO LEN(Y$) : C$=MID$(Y$,II,1)
710 GOSUB 720 :NEXT II:PRINT:GOTO 690
720 REM this routine discards non-Morse characters
730 PRINT C$; :IF PR THEN PRINT #1,C$;
740 C=(ASC(C$) AND 127 OR 32):IF C<45 THEN RETURN
750 IF C=32 THEN SOUND SP,7*V:RETURN
760 C$=CHR$(C) : FOR X=1 TO 40
770 IF MID$(H$,X,1)=C$ THEN 790
780 NEXT X: IF X >40 THEN SOUND SP,7*V:GOTO 800
790 GOSUB 460
800 RETURN
810 END
820 E$="":C=0:P=0
830 CLS:PRINT "MORSE-IT : receiver section "
840 DEF SEG=0
850 PORTA=&H201
860 REM game port address
870 REM on my PC clone :
880 REM a value of 176 on game port indicates "close key condition"
890 REM a value of 240 indicates "open key condition"
900 REM check these values on YOUR PC if MORSE-IT seems not to work!
910 I=INP(PORTA)
920 REM inputs a value from the game port
930 IF I=240 THEN P=P+1:GOTO 910
940 REM P computes the time of "key open" condition during
950 REM character parsing :
960 REM change the values of P if your computer is faster or
970 REM slower (!!!) than a 4.77 MHz standard PC.
980 REM increase P values if faster, decrease if slower
990 REM
1000 IF P>150 THEN GOSUB 1220:GOSUB 1260:E$="":C=0 :GOTO 1100
1010 REM
1020 REM key open condition for a "P" (pause) value > 150 means that
1030 REM a character has been parsed
1040 REM
1050 IF P>30 THEN GOSUB 1220: C=0
1060 REM
1070 REM key off condition for a "P" value greater than 30 means that
1080 REM a character element (dot or line) has been parsed
1090 REM
1100 P=0:IF I=176 THEN C=C+1:GOTO 910
1110 REM
1120 GOTO 910
1130 END
1140 REM C computes the "key closed" duration :
1150 REM change the values of C if your computer is faster or slower
1160 REM than a standard P.C. (4.77 MHz clock)
1170 REM increase if faster, decrease if slower...
1180 REM
1190 REM C > 40 means that a "line" has been detected
1200 REM C<= 40 indicate that a "dot" has been detected
1210 REM
1220 IF C<=40 THEN E$=E$+"0"
1230 IF C> 40 THEN E$=E$+"1"
1240 C=0
1250 RETURN
1260 REM
1270 FLAG=0:FOR I=1 TO 40
1280 IF E$=A$(I) THEN PRINT MID$(H$,I,1);:FLAG=I
1290 NEXT:IF FLAG=0 THEN PRINT "*";
1300 C=0:E$="":IF P>700 THEN PRINT " ";
1310 REM
1320 FLAG=0:RETURN
1330 CLS: PRINT "Morse-it detected an error... check your hardware"
1340 PRINT "and re-run program."
1350 FOR I=1 TO 10000 : NEXT I:SYSTEM